<template>
	<view class="content">
		<nav-bar :title="$t('我的流量包')" leftIcon="left"></nav-bar>
		<!-- 		<view class="content-1">
			<view class="listMain">
				<view class="tit">
					<text class="text">{{ $t('購買流量總和GB') }}:</text>
					<image class="img zy" v-if="showIncome" src="@/assets/myFlow/zhenyan.png" @click="changeShow"></image>
					<image class="img by" v-else src="@/assets/myFlow/biyan.png" @click="changeShow"></image>
				</view>
				<view class="num">
					{{ !showIncome ? flowList.flowAmountTotal : '— —' }}
				</view>
			</view>
		</view> -->
		<!-- 		<view class="content-1">
			<view class="listMain">
				<view class="tit">
					<text class="text">{{ $t('解鎖總流量GB') }}:</text>
					<image class="img zy" v-if="showIncomeJs" src="@/assets/myFlow/zhenyan.png" @click="changeShowJs">
					</image>
					<image class="img by" v-else src="@/assets/myFlow/biyan.png" @click="changeShowJs"></image>
				</view>
				<view class="num">
					{{ !showIncomeJs ? flowList.flowUnlockTotal : '— —' }}
				</view>
			</view>
		</view>
		<view class="content-1">
			<view class="listMain">
				<view class="tit">
					<text class="text">{{ $t('未解鎖流量GB') }}:</text>
					<image class="img zy" v-if="showIncomeWjs" src="@/assets/myFlow/zhenyan.png" @click="changeShowWjs">
					</image>
					<image class="img by" v-else src="@/assets/myFlow/biyan.png" @click="changeShowWjs"></image>
				</view>
				<view class="num">
					{{ !showIncomeWjs ? flowList.flowLockTotal : '— —' }}
				</view>
			</view>
		</view> -->
		<view class="banner">
			<!-- <image class="img" src="@/assets/index/1@2x.png"></image> -->
			<view class="iconYjNum">
				<view class="bannerTop">
					{{ $t('流量數量') }}
				</view>
				<view class="yjNum">
					<image v-if="showIncomeJs" src="@/assets/myFlow/zhenyan.png" @click="changeShowJs"
						style="width: 40rpx;height: 40rpx;">
					</image>
					<image v-else src="@/assets/myFlow/biyan.png" @click="changeShowJs"
						style="width: 40rpx;height: 40rpx;">
					</image>
				</view>
			</view>
			<view class="bannerBotton">
				<!-- {{ !showIncomeJs ? flowList.flowUnlockTotal : '— —' }} -->
				<view v-if="!showIncomeJs">{{ flowList.flowLockTotal || 0 }}T</view>
				<view v-else> ****** </view>
			</view>
		</view>
		<view class="content-2">
			<view class="tit">
				{{ $t('流量包列表') }}
			</view>
			<view v-if="flowListLl.length !== 0" class="btn" @click="handleBack">
				{{ $t('銷燬流量包') }}
			</view>
		</view>
		<view class="content-3">
			<view class="con4-item" v-for="item in flowListLl" :key="item.flowId">
				<view class="title">
					<!-- <image class="icon" src="@/assets/index/lll.png"></image> -->
					<image class="icon" src="@/assets/index/1.png" v-if="item.flowId == 1"></image>
					<image class="icon" src="@/assets/index/2.png" v-if="item.flowId == 2"></image>
					<image class="icon" src="@/assets/index/3.png" v-if="item.flowId == 3"></image>
					<view class="text">
						{{ $t(`${item.flowName}`) }}
					</view>
				</view>
				<view class="data">
					<view class="jg num">
						<span>{{ item.flowPrice }} </span><span>CFP</span><br>
						<span>{{ $t('價格') }}</span>
					</view>
					<view class="ll num">
						<span>{{ item.flowAmount }} </span><span>GB</span><br>
						<span>{{ $t('流量') }}</span>
					</view>
					<view class="cz num">
						<span>{{ item.totalAmount }} </span><span>CFP</span><br>
						<span>{{ $t('產值') }}</span>
					</view>
				</view>
				<view class="border"></view>
				<view class="bot-num">
					<view class="cc text">
						{{ $t('每日預估產出') }}:{{ item.predictAmountTo }}CFP
					</view>
					<view class="xs text">
						{{ $t('纍計購買') }}<span style="color: #11F6FA;"
							class="num">{{ item.flowNumberCount }}</span><span>{{
							$t('個') }}</span>
					</view>
				</view>
			</view>
		</view>
		<!-- 		<m-tabbar fixed fill :current="999"></m-tabbar> -->
		<view v-if="flowListLl.length === 0" class="nomore"
			style="display: flex;justify-content: center;align-items: center;flex-direction: column;margin-top: 70px;">
			<image style="width: 130px;height: 130px;" src="@/assets/myFlow/nomore.png" mode=""></image>
			<span style="color: #FFFFFF;">{{ $t('乜都冇哦') }}～</span>
		</view>
	</view>
</template>

<script setup>
	import {
		computed,
		onMounted,
		ref
	} from 'vue'
	import {
		onShow,
		onReachBottom
	} from '@dcloudio/uni-app'
	import myFlowRequest from '@/hooks/myFlow.js'
	const {
		list,
		details,
		page,
		size,
		sumComputed,
		getMyFlow,
		getMyFlowMoney
	} = myFlowRequest()
	const flowList = ref({})
	const getMyFlowMoneyValue = ref({})
	const flowListLl = ref([])
	const showIncome = ref(false)
	const showIncomeJs = ref(false)
	const showIncomeWjs = ref(false)
	onShow(async()=>{
		let list = {
			userId: uni.getStorageSync('setUserInfo').userId
		}
		let dataMyFlowMoney = await getMyFlow('user-flow-inventory/flowUser', list)
		if (!dataMyFlowMoney.flowLockTotal) {
			dataMyFlowMoney.flowLockTotal = '0'
			flowList.value = dataMyFlowMoney
		} else {
			flowList.value = dataMyFlowMoney
		}
		
		let dataMyFlowLl = await getMyFlow('user-flow-inventory/flowUserlist', list)
		flowListLl.value = dataMyFlowLl
		let getMyFlowMoneyValueData = await getMyFlowMoney('user/personalCenter', list)
		if (getMyFlowMoneyValueData.totalAmountFlow > 0) {
			getMyFlowMoneyValueData.totalAmountFlow = getMyFlowMoneyValueData.totalAmountFlow.toFixed(5)
		}
		getMyFlowMoneyValue.value = getMyFlowMoneyValueData
	})
	const changeShow = () => {
		showIncome.value = !showIncome.value
	}
	const changeShowJs = () => {
		showIncomeJs.value = !showIncomeJs.value
	}
	const changeShowWjs = () => {
		showIncomeWjs.value = !showIncomeWjs.value
	}
	const handleBack = () => {
		uni.navigateTo({
			url: '/pages/recycle/recycle'
		})
	}
</script>

<style lang="scss" scoped>
	.yjNum {
		position: absolute;
		margin-left: 250rpx;
	}

	.iconYjNum {
		display: flex;

	}

	.banner {
		position: relative;
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: column;
		width: 100%;
		height: 263rpx;
		background-image: url('@/assets/index/banner.png');
		background-size: cover;
		background-position: center;
		margin-bottom: 20px;

		.bannerTop {

			font-size: 13px;
			font-family: PingFang SC;
			font-weight: 300;
			color: #12FFFA;

		}

		.bannerBotton {

			font-size: 35px;
			font-family: DIN Alternate;
			font-weight: bold;
			color: #12FFFA;
		}

		.by {
			position: absolute;
			top: 47px;
			right: 25px;
			width: 43px;
			height: 43px;
		}
	}

	.content-1 {
		width: 690rpx;
		box-sizing: border-box;
		// background: url("@/assets/myFlow/beijin.png");
		// background-size: 100% 100%;
		padding: 30rpx;
		border-radius: 15rpx;
		// display: flex;
		// align-items: center;
		// justify-content: space-between;
		// flex-wrap: wrap;
		margin-bottom: 15rpx;
		background-color: #6958d6;

		.tit {
			.text {
				font-size: 28rpx;
				color: #fff;
				font-family: PingFangSC-Regular;
				font-weight: Regular;
			}

			.img {
				width: 28rpx;
				height: 28rpx;
				margin-left: 11rpx;
			}

			.by {
				width: 28rpx;
				height: 28rpx;
				height: 14rpx;
			}

			.zy {
				position: relative;
				top: 5rpx;
			}

		}

		.num {
			margin-top: 10rpx;
			font-size: 45rpx;
			color: #fff;
			font-family: DINAlternate-Bold;
			font-weight: bold;
		}
	}

	.content-2 {
		margin-top: 12rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		width: 100%;

		.tit {
			font-size: 30rpx;
			font-family: PingFangSC-Medium;
			font-weight: Medium;
			color: #fff;
		}

		.btn {
			width: 185rpx;
			height: 60rpx;
			background: linear-gradient(90deg, #039BDA, #0DF2ED);
			border-radius: 30rpx;
			line-height: 60rpx;
			text-align: center;
			font-size: 24rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #FFFFFF;
		}
	}

	.content-3 {
		margin-top: 45rpx;
		width: 100%;

		.con4-item {
			width: 100%;
			box-sizing: border-box;
			min-height: 290rpx;
			background: #24232C;
			border-radius: 15rpx;
			margin-bottom: 30rpx;
			padding: 30rpx 25rpx 28rpx 26rpx;

			.title {
				display: flex;
				align-items: center;

				.icon {
					width: 103rpx;
					height: 69rpx;
				}

				.text {
					font-size: 34rpx;
					margin-left: 17rpx;
					color: #fff;
					font-weight: Medium;
					font-family: PingFangSC-Medium;
				}
			}

			.data {
				margin-top: 12rpx;
				display: flex;

				.num {
					width: 230rpx;

					:nth-child(1) {
						font-size: 36rpx;
						font-weight: Bold;
						color: #FFF;
						font-family: DINAlternate-Bold;
					}

					:nth-child(2) {

						color: #FFF;
						font-size: 22rpx;
						font-weight: lighter;
						font-family: PingFangSC-Light;
					}

					:nth-child(4) {
						color: #808492;
						font-size: 22rpx;
						font-weight: lighter;
						font-family: PingFangSC-Light;
					}
				}
			}

			.border {
				width: 100%;
				height: 1rpx;
				background: #23262F;
				border-bottom: 1rpx solid #FFFFFF;
				margin-top: 20rpx;
				opacity: 0.05;
			}

			.bot-num {
				display: flex;
				margin-top: 20rpx;
				justify-content: space-between;

				.text {
					color: #808492;
					font-size: 24rpx;
					font-weight: Regular;
					font-family: PingFangSC-Regular;
				}

				.num {
					color: rgb(249, 171, 112);
				}
			}
		}
	}
</style>